package com.younger.transistion;

import android.app.ActivityOptions;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.transition.Explode;
import android.transition.Fade;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    Button btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btn = (Button) findViewById(R.id.btn);
//        setupWindowsTransition();
    }

    private void setupWindowsTransition() {
        Log.i("Tag", android.os.Build.VERSION.SDK_INT + "");
        Explode explode = null;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            explode = new Explode();
            explode.setDuration(10000);
            getWindow().setExitTransition(explode);

            Fade fade = new Fade();
            fade.setDuration(3000);
            getWindow().setReenterTransition(fade);
        }

    }

    public void go(View view) {
        Intent intent = new Intent(this, BActivity.class);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this, btn, "xixi").toBundle());
        } else {
            startActivity(intent);
        }
    }
}
